<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace app\blog\controller;
use app\admin\model\UserModel;
use app\blog\model\BusinessModel;
use app\blog\model\StoreModel;
use App\Http\Model\Home\goods;
use cmf\controller\AdminBaseController;
use think\Db;
class MemberController extends AdminBaseController
{
    public function index(){
        return $this->fetch();
    }
    function datum(){
        //会员资料      
        $adminid = cmf_get_current_admin_id();        
        $uinfo=get_operator_data($adminid);
        $where=array();
        $mobile = $this->request->param('mobile');
        isset($mobile)?$where['mobile']=$mobile:'';
        //权限判断
        $store_str='';     
        $userList=get_user_list($adminid);
        $uid_list_str=toStr($userList,'userid');
        $uid_list_str.=','.$adminid;
        $store_id_list=get_store_list($uid_list_str);
        if($store_id_list){
            $where['store_id']=array('in',$store_id_list);           
        }
        $list = Db::name('member')->where($where)->order('id desc')->paginate(10);
        //echo Db::name('member')->getlastsql();
        $page = $list->render();
        $this->assign("page", $page);
        $this->assign('list',$list);
        return $this->fetch();
    }
    function del(){
        $param = $this->request->param();
        $param=$param['idnumber'];
        DB::name('member')->where('idnumber',$param)->delete();
        $this->success('删除成功');
    }
    function consume(){
        //会员消费记录查询
        return $this->fetch();
    }
    function edit(){
        $param = $this->request->param();
        $paramt=$param['idnumber'];
        $member=DB::name('member')->where('idnumber',$paramt)->select();
        $this->assign('member',$member);
        $store_name=DB::name('store')->column('store_name');
        $this->assign('store_name',$store_name);
        return $this->fetch('edit');
    }
}